package com.eddie.hhcook.utils;

import android.annotation.TargetApi;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.eddie.hhcook.view.listviewanimations.appearance.AnimationAdapter;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.ObjectAnimator;
import com.nineoldandroids.animation.ValueAnimator;

public class ListViewAnimationAdapter extends AnimationAdapter {


    public ListViewAnimationAdapter(BaseAdapter baseAdapter) {
        super(baseAdapter);
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @Override
    public Animator[] getAnimators(ViewGroup parent, final View view) {

       ObjectAnimator bottomInAnimator = ObjectAnimator.ofFloat(view, "xby", 0.9F,  1.0F);
        bottomInAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float cVal = (Float) valueAnimator.getAnimatedValue();
                view.setAlpha(cVal);
                view.setScaleX(cVal);
                view.setScaleY(cVal);
            }
        });

        return new Animator[] { bottomInAnimator};
    }

}